package edu.nf.takeoutdemo.web.user;

import edu.nf.takeoutdemo.commons.base.BaseController;
import edu.nf.takeoutdemo.commons.constant.StatusConstant;
import edu.nf.takeoutdemo.commons.result.Result;
import edu.nf.takeoutdemo.model.entity.Setmeal;
import edu.nf.takeoutdemo.model.vo.DishItemVO;
import edu.nf.takeoutdemo.service.SetmealService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *
 * @author zjl
 * @date 2025/10/28
 */
@RestController("userSetmealController")
@Slf4j
@RequestMapping("/user/setmeal")
@RequiredArgsConstructor
public class SetmealController extends BaseController {
    private final SetmealService setmealService;

    @GetMapping("/list")
    public Result<List<Setmeal>> list(Long categoryId){
        Setmeal setmeal = new Setmeal();
        setmeal.setCategoryId(categoryId);
        setmeal.setStatus(StatusConstant.ENABLE);
        List<Setmeal> setmealList = setmealService.list(setmeal);
        return success(setmealList);
    }

    @GetMapping("/dish/{id}")
    public Result<List<DishItemVO>> dishList(@PathVariable("id") Long id){
        List<DishItemVO> dishItemVOList = setmealService.getDishItemById(id);
        return success(dishItemVOList);
    }
}
